import { Type } from '@angular/core';

export abstract class StoreBase<T> {
  protected readonly storePath: string;

  public static get staticStorePath(): string {
    return this['NGXS_META'].path;
  }

  constructor(storeClass: Type<T>) {
    this.storePath = storeClass['NGXS_META'].path;
  }

  protected setup(storeClass: Type<T>, ...actions: string[]) {
    actions.forEach(fn => {
      const actionName = `[${this.storePath}] ${fn}`;
      storeClass['NGXS_META'].actions[actionName] = [
        {
          fn: fn,
          options: {},
          type: actionName,
        },
      ];
    });
  }
}
